<?php


namespace App\Services\Game;


use App\DTOS\Admin\HorseRaceLampDTO;
use App\Models\Game\HorseRaceLamp;

class HorseRaceLampService
{

    /**
     * @param HorseRaceLampDTO $dto
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
     */
    public function paginate(HorseRaceLampDTO $dto){
        $pageSize = $dto->getLimit();
        $page = $dto->getPage();
        $status = $dto->getStatus();
        $title = $dto->getTitle();
        $content = $dto->getContent();
        $model = HorseRaceLamp::query();
        if ($status){
            $model->where('begin_time',"<",time())->where('end_time',">",time());
        }
        if ($title){
            $model->where('title',"like","%$title%");
        }
        if ($content){
            $model->where('content',"like","%$content%");
        }
        return $model->orderByDesc('id')->paginate($pageSize,'*','page',$page);
    }

}
